// src/utils/time.js
export function formatDuration(ms) {
	const s = Math.max(0, Math.floor(ms / 1000))
	const hh = String(Math.floor(s / 3600)).padStart(2, '0')
	const mm = String(Math.floor((s % 3600) / 60)).padStart(2, '0')
	const ss = String(s % 60).padStart(2, '0')
	return `${hh}:${mm}:${ss}`
}

export function formatPace(totalMs, meters) {
	if (!meters || meters < 1) return `--'--"`
	const perKm = totalMs / (meters / 1000) // ms / km
	const m = Math.floor(perKm / 60000)
	const s = Math.floor((perKm % 60000) / 1000)
	return `${String(m).padStart(2, '0')}'${String(s).padStart(2, '0')}"`
}